home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 011 / dossub.asm < prev    next >
Assembly Source File  |  1985-06-03  |  4KB  |  132 lines

  1.  
  2. ; DOSSUB - general dos subroutine interface for compiled BASIC
  3. ; CALL DOSSUB(RETCD%,INTNO%,AH%,AL%,BH%,BL%,CH%,CL%,DH%,DL%)
  4. ; RETCD% is the error return code (0 if no error)
  5. ; INTNO% is the interrupt number (0 to 255)
  6. ; AH% is the argument corresponding to register AH
  7. ; AL% is the argument corresponding to register AL
  8. ; BH% is the argument corresponding to register BH
  9. ; BL% is the argument corresponding to register BL
  10. ; CH% is the argument corresponding to register CH
  11. ; CL% is the argument corresponding to register CL
  12. ; DH% is the argument corresponding to register DH
  13. ; DL% is the argument corresponding to register DL
  14. cseg segment para public 'code'
  15. public dossub
  16. dossub proc far
  17.     assume cs:cseg,ds:nothing,ss:nothing,es:nothing
  18.     push bp
  19.     mov bp,sp
  20.  
  21. p20:               ; temporarily change fatal error vector
  22.     mov ax,0
  23.     mov ds,ax
  24.     mov ax,[ds:90h]; get fatal error ip
  25.     push ax        ; save ip
  26.     mov ax,[ds:92h]; get fatal error cs
  27.     push ax        ; save cs
  28.     call p25       ; get ip
  29. p25:
  30. a25 equ this byte
  31.     pop bx         ; ip in bx
  32.     add bx,a50-a25
  33.     mov ds:90h,bx  ; ip of vector
  34.     push cs        ; set fatal error cs
  35.     pop ax         ; set ds to cs
  36.     mov ds:92h,ax  ; cs of vector
  37.     mov ax,es
  38.     mov ds,ax      ; restore ds
  39.  
  40. p30:               ; set registers for call
  41.     mov si,[bp+20] ; point to ah argument
  42.     mov ah,[si]
  43.     mov si,[bp+18] ; point to al argument
  44.     mov al,[si]
  45.     mov si,[bp+16] ; point to bh argument
  46.     mov bh,[si]
  47.     mov si,[bp+14] ; point to bl argument
  48.     mov bl,[si]
  49.     mov si,[bp+12] ; point to ch argument
  50.     mov ch,[si]
  51.     mov si,[bp+10] ; point to cl argument
  52.     mov cl,[si]
  53.     mov si,[bp+8]  ; point to dh argument
  54.     mov dh,[si]
  55.     mov si,[bp+6]  ; point to dl argument
  56.     mov dl,[si]
  57.  
  58. p40:               ; set up for call
  59.     push ax
  60.     push bx
  61.     mov si,[bp+22] ; point to interrupt no
  62.     mov al,[si]    ; interrupt in al
  63.     call p45
  64. p45:
  65. a45 equ this byte
  66.     pop bx         ; ip in bx
  67.     add bx,a46-a45+1
  68.     mov cs:[bx],al ; set interrupt
  69.     pop bx
  70.     pop ax
  71.     push bp        ; save bp - bios bug
  72. a46 equ this byte
  73.     int 00h        ; overlaid by intno%
  74.     jmp p60        ; skip err control
  75.  
  76. p50:               ; handle fatal error
  77. a50 equ this byte
  78.     sti            ; interrupts back on
  79.     mov ax,di      ; get error code
  80.     mov ah,0       ; error in al
  81.     add sp,18      ; skip unneeded stack
  82.     pop bp
  83.     pop ds
  84.     pop es
  85.     add sp,6
  86.     pop bp         ; restore bp - bios bug
  87.     mov si,[bp+24]
  88.     mov [si],ax    ; return error
  89.     jmp p70        ; restore orig vector
  90.  
  91. p60:               ; return register values
  92.     pop bp         ; restore bp - bios bug
  93.     mov si,[bp+20] ; point to ah argument
  94.     mov [si],ah
  95.     mov si,[bp+18] ; point to al argument
  96.     mov [si],al
  97.     mov si,[bp+16] ; point to bh argument
  98.     mov [si],bh
  99.     mov si,[bp+14] ; point to bl argument
  100.     mov [si],bl
  101.     mov si,[bp+12] ; point to ch argument
  102.     mov [si],ch
  103.     mov si,[bp+10] ; point to cl argument
  104.     mov [si],cl
  105.     mov si,[bp+8]  ; point to dh argument
  106.     mov [si],dh
  107.     mov si,[bp+6]  ; point to dl argument
  108.     mov [si],dl
  109.  
  110. p70:               ; reset fatal error vector
  111.     mov ax,0
  112.     mov ds,ax
  113.     pop ax         ; re-set fatal error vector
  114.     mov ds:92h,ax  ; restore original cs
  115.     pop ax
  116.     mov ds:90h,ax  ; restore original ip
  117.     mov ax,es
  118.     mov ds,ax      ; restore ds
  119.  
  120. p80:               ; return to caller
  121.     pop bp
  122.     ret 20
  123.  
  124. dossub endp
  125. cseg ends
  126.     end
  127. 
  128.  
  129.       ; restore ds
  130.  
  131. p80:               ; return to caller
  132.     pop bp